package com.example.esaclient;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.os.AsyncTask;
import android.util.Log;


public class MyPostsTW extends AsyncTask<Object, Integer, Boolean> {
 

	private static final String NAMESPACE = "http://tempuri.org/";
	private static final String URL = "http://192.168.0.6:80/ServiceRest.svc";
	private  static final String METHOD_NAME = "MyPostsTW";
	private static final String SOAP_ACTION = "http://tempuri.org/IServiceRest/";
	TabUserTimeline caller;
	
	@Override
	protected Boolean doInBackground(Object... params) {
		
		caller= (TabUserTimeline)params[1];
		
		 try {
	         SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);         
	         request.addProperty("id", params[0]);	         
	         
	          
	         
	         
	         SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
	         envelope.dotNet= true;		         
	         envelope.setOutputSoapObject(request);
	          
	         HttpTransportSE ht = new HttpTransportSE(URL);	        
	         ht.call(SOAP_ACTION+METHOD_NAME, envelope);                 	        
	          
	          final String result= envelope.getResponse().toString();
	          Log.e("ESA Service result: ",">"+ result);
	          
	          if(result.equals("true"))  return true;
	          else return false;
 	         
	      }
	     catch (final Exception e) {
	         e.printStackTrace();    	         
	     	return false;
	     }
	
	    
	
	}
	
	

	     protected void onPostExecute(Boolean result) {
	    	 //caller.esaResult(result);
	     }
}